package com.cium.aqie.myClass

/**
 * @Function:
 * @Author: aqie
 * @Date: 2019/8/27 11:42
 */
open class People(var nature: String, var look: String, var voice: String) {
    init {
        println("new 了一个${this.javaClass.simpleName}, ta性格:$nature, 长相:$look, 声音:$voice")
    }
}

fun main() {
    val myGirl: Girl = Girl("温柔", "甜美", "动人")
    val myBoy: Boy = Boy("彪悍", "帅气", "浑厚")
    println(myGirl is People)

    var girl : People = Girl("温柔", "甜美", "动人")
    // 如果 girl是 Girl实例, 智能转换
    if (girl is Girl){
        println(girl.getInfo())
    }

    // 强转  ClassCastException   as后加? 返回null, 安全类型转换
    var people : People = People("","","")
    val boy:Boy? = people as? Boy
    print(boy)

}